package cn.zero.repository;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import cn.zero.model.Wallet;

public interface WalletRepository extends BaseRepository<Wallet> {

	Wallet getByUserId(Long userId);

	@Modifying
	@Query("update Wallet w set w.balance=w.balance+:amount where w.id=:id")
	int change(@Param("id") Long id, @Param("amount") double amount);

	@Query("select sum(w.balance) from Wallet w")
	Double sumBalance();

}
